package cn.johnnyjian.getris.game.quadrel

import static org.junit.Assert.assertArrayEquals
import static org.junit.Assert.assertEquals
import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.runners.Parameterized.Parameters

@RunWith (Parameterized)
class QuadrelSixTest {

	static quadrel
	def squares
	def offset

	@Parameters static data() {
		[
			[
				[
					[0, 1],
					[0, 1],
					[1, 1]
				],
				[left: 0, top: 0]
			],
			[
				[
					[1, 0, 0],
					[1, 1, 1]
				],
				[left: 0, top: 0]
			],
			[
				[
					[1, 1],
					[1, 0],
					[1, 0]
				],
				[left: 1, top: 0]
			],
			[
				[
					[1, 1, 1],
					[0, 0, 1]
				],
				[left: 0, top: 1]
			]
		].collect { it as Object[] }
	}

	QuadrelSixTest(a, b) {
		squares = a as boolean[][]
		offset = b
	}

	@BeforeClass static void createQuadrel() {
		quadrel = new QuadrelSix()
	}

	@Test void testRotate() {
		assertArrayEquals squares, quadrel.rotate().squares
		assertEquals offset, quadrel.offset
		assertEquals 3, quadrel.bound
	}

}
